#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

DRV_API_MAJOR := 0
DRV_API_MINOR := 10
DRV_API_FUNC := 2
DRV_API_DEPEND := bio-drv-api-$(DRV_API_MAJOR).$(DRV_API_MINOR)

APP_API_MAJOR := 0
APP_API_MINOR := 11
APP_API_FUNC := 1
APP_API_DEPEND := bio-app-api-$(APP_API_MAJOR).$(APP_API_MINOR)


# main packaging script based on dh7 syntax
%:
	dh $@ --with python3

# debmake generated override targets
# This is example for Cmake (See http://bugs.debian.org/641051 )
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure -- \
			--enable-static \
			--enable-shared \
			--with-bio-db-dir=/var/lib/biometric-auth/ \
			--with-bio-db-name=biometric.db \
			--with-bio-config-dir=/etc/biometric-auth/ \
			--with-bio-driver-dir=/usr/lib/biometric-authentication/drivers \
			--with-bio-extra-dir=/usr/lib/biometric-authentication/drivers/extra \
			--libexecdir=\$${prefix}/lib/biometric-authentication

override_dh_auto_install:
	dh_auto_install
	mkdir -p debian/tmp/usr/share/biometric-auth/
	mv debian/tmp/etc/biometric-auth/biometric-drivers.conf \
		debian/tmp/usr/share/biometric-auth/biometric-drivers.conf.template

override_dh_gencontrol:
	echo "bio-app-api:Provides=$(APP_API_DEPEND)" >> debian/biometric-auth.substvars;
	echo "bio-drv-api:Provides=$(DRV_API_DEPEND)" >> debian/libbiometric0.substvars;
	dh_gencontrol -- -V"bio-drv-api:Depends=$(DRV_API_DEPEND)"
